feat: add prompt variable compilation#28
Conversation
Add PromptTemplate and PromptCompiler utilities for {{variable}}
template compilation, matching the Python/JS SDK compile() behavior.
|
@ChoMinGi Thank you a lot! Did you test whether a regeneration of the client using |
|
Hi @Steffen911, thanks for the review! I confirmed that Fern regeneration does not affect the files added in this PR. |
|
Thanks for reviewing and merging this, @Steffen911! |
Summary
Adds PromptTemplate and PromptCompiler under com.langfuse.client.prompt — no changes to Fern-generated code.
PromptTemplate handles {{var}} replacement and variable extraction. PromptCompiler wraps it for TextPrompt and ChatPrompt types so the usage feels similar to the Python/JS SDKs.
Tests cover basic replacement, missing/extra vars, null handling, edge cases for both text and chat prompts.
Closes #13
Scope
PlaceholderMessageexpansion (inserting message lists at placeholder positions) — not included in this PR, planned as a follow-upTest plan
PromptTemplate(basic replacement, missing/extra vars, null handling, whitespace, edge cases)PromptCompiler(text prompt, chat prompt, placeholder skipping, empty prompt)